﻿@page "/"
@using ZXingBlazor.Components

@if (ShowScanBarcode)
{

    <BarcodeReader ScanResult="OnResult"
                   Close="(()=>ShowScanBarcode=!ShowScanBarcode)"
                   Decodeonce="false" />
}

<button @onclick="_ =>  ShowScanBarcode = !ShowScanBarcode">扫码</button>
<pre>
    @result
</pre>

@code{
    /// <summary>
    /// 显示扫码界面
    /// </summary>
    bool ShowScanBarcode { get; set; } = false;

    string result;

    private Task OnResult(string message)
    {
        result += message + Environment.NewLine;
        StateHasChanged();
        return Task.CompletedTask;
    }

}


@if (!ShowScanBarcode)
{
    <div class="row g-10 mt-3">
        <div class="col-12 col-sm-4">

            <Capture />
        </div>
    </div>
}